import { defineStore } from 'pinia';
import { GetCartList, CartItem } from '@/api/cart/index';

export const useCartList = defineStore('cart', {
  state: () => ({
    cartList: <CartItem[]>[],
  }),
  actions: {
    //获取购物车列表
    async getCartList() {
      try {
        let data = await GetCartList();
        // console.log(data);
        if (data[0]) {
          this.cartList = data[0].cartInfoList;
        }
      } catch (error) {
        console.log('请求购物车列表失败');
      }
    },
    // 切换商品选中状态
  },

  getters: {},
});
